import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;


public class SortingMain {

	public static void main(String[] args) {
		List<Person> persons = new ArrayList<Person>();
		persons.add(new Person("Bush", "George", 59, 90));
		persons.add(new Person("Truman", "Harry", 60, 91));
		persons.add(new Person("Clinton", "Bill", 61, 92));
		persons.add(new Person("Reagan", "Ronald", 57, 83));
		
		Collections.sort(persons, new Comparator<Person>() {
			@Override
			public int compare(Person p1, Person p2) {
				int c = p1.age - p2.age;
				if (c != 0) {
					return c;
				}
				
				c = p1.weight - p2.weight;
				if (c != 0) {
					return c;
				}
				
				c = p1.last.compareTo(p2.last);
				if (c != 0) {
					return c;
				}
				
				c = p1.first.compareTo(p2.first);
				return c;
			}
		});
		
		for (Person p : persons) {
			System.out.println(p);
		}
	}
	
	private static class Person{
		String last;
		String first;
		int age;
		int weight;
		public Person(String last, String first, int age, int weight) {
			this.last = last;
			this.first = first;
			this.age = age;
			this.weight = weight;
		}
		@Override
		public String toString() {
			return "Person [last=" + last + ", first=" + first + ", age=" + age
					+ ", weight=" + weight + "]";
		}
	}
}
